<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Models\Config;
use Illuminate\Http\Request;

class ConfigController extends Controller {

    //配置
    public function index(){
        $config = Config::pluck('setting','name')->toArray();
        return $this->writeJson(0,$config);
    }

    //更新
    public function update(Request $request)
    {
        $data = $request->all();
        $info = Config::where('name',$data['type'])->first();
        unset($data['type']);
        $info->update(['setting' => $data]);
        return $this->writeJson(0,null,'更新配置信息成功');
    }

}
